package project.dade.cn.bst.base;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MotionEvent;
import android.widget.TextView;

import butterknife.ButterKnife;
import dmax.dialog.SpotsDialog;
import project.dade.cn.bst.R;
import project.dade.cn.bst.utils.Util;


/**
 * Created by 周大大 on 2015/7/24.·
 */
public class ZJPBaseBarActivity extends SwipeBackActivity {
    protected static String TAG =ZJPBaseBarActivity.class.getSimpleName();

    public Toolbar toolbar;
    protected TextView toolbarTitle;
    protected SpotsDialog mSpDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
        toolbar = (Toolbar) findViewById(R.id.universal_toolbar);
        toolbarTitle = (TextView) findViewById(R.id.universal_toolBarTitle);
        ButterKnife.inject(this);
//        Util.addActivity(this);
        setupToolbar();

    }

    protected void setupToolbar() {
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            setNavigationIcon(0);
            getSupportActionBar().setDisplayShowTitleEnabled(false);

        }
    }

    public void setNavigationIcon(int resId) {
        if (resId != 0) {
            toolbar.setNavigationIcon(resId);
        } else {
            toolbar.setNavigationIcon(R.drawable.ic_menu_arrow_back_white);
        }

    }


    /**
     * 设置定制居中的标题
     */
//    public void setCustomStatusTitle(int strId) {
//        toolbarTitle.setText(strId);
//    }

    /**
     * 设置定制居中的标题
     */
    public void setCustomStatusTitle(String str) {
        toolbarTitle.setText(str);
    }


    public void setToolBarTitle(String str) {
        toolbarTitle.setText(str);
    }

    public void setToolBarTitle(int str) {
        toolbarTitle.setText(str);
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        this.finish();
    }

    protected int getActionBarTitle() {
        return R.string.app_name;
    }
    @Override
    protected void onResume() {
        super.onResume();
        //注：回调 1
    }

    @Override
    protected void onPause() {
        super.onPause();
        //注：回调 2

    }
   

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        //注：回调 3
        return super.dispatchTouchEvent(event);
    }
    @Override
    protected void onDestroy() {
//      Util.  removeActivity(this);
        super.onDestroy();
    }

}
